package com.itheima.core;

import com.itheima.core.inter.SqlSessionFactory;
import com.itheima.core.domain.Configuration;
import com.itheima.core.utils.XMLConfigBuilder;
import org.dom4j.DocumentException;

import java.io.InputStream;

/**
 * 分装了解析xml文件的繁琐步骤,可以创建SqlSessionFactory对象
 * @author slstart
 * @create 2021-05-04 13:57
 */
public class SqlSessionFactoryBuilder {

    private Configuration cfg;

    public SqlSessionFactory build(InputStream is) throws DocumentException {
        Configuration cfg = XMLConfigBuilder.buildConfiguration(is);
        return new DefaultSqlSessionFactory(cfg);
    }

}
